package com.cr.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
 * 
 * @author cyxl
 *
 */
public class ConfigManager {
	
	private static ConfigManager instance;
	private Properties properties;

	private ConfigManager() {
		init();
	}

	private void init() {
		properties = new Properties();
		InputStream is = null;
		try {
			ClassLoader loader=getClass().getClassLoader();
			is = loader.getResourceAsStream("config.properties");
			properties.load(is);
		} catch (Exception e) {
			System.out.println("Error");
		} finally {
			try {
				if (is != null) {
					is.close();
				}
			} catch (IOException ioe) {
			}
		}

	}

	/**
	 * 
	 * @return
	 */
	public static ConfigManager getInstance() {
		if (instance == null) {
			instance = new ConfigManager();
		}
		return instance;
	}

	
	public String getValue(String key) {
		return properties.getProperty(key);
	}
}
